package ${packageName}.common;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

/**
* @author 19324
*/
@Data
public class R<${t_name}> implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    /**
    * 结果
    */
    private boolean flag;
    /**
    * 数据
    */
    private T data;

    /**
    * 描述
    */
    private String message;

    public R(boolean flag, T data, String message) {
        this.flag = flag;
        this.data = data;
        this.message = message;
    }

    public static <${t_name}> R<${t_name}> success(T data, String message) {
         return new R<>(true, data, message);
    }

    public static <${t_name}> R<${t_name}> success(String message) {
          return new R<>(true, null, message);
    }

    public static <${t_name}> R<${t_name}> error(T data, String message) {
          return new R<>(false, data, message);
    }

    public static <${t_name}> R<${t_name}> error(String message) {
           return new R<>(false, null, message);
    }

}
